//引入接口
import API from '../../config/server.js'
Page({
  data:{
    skinList:[]
  },
  onLoad()
  {
    this.getSkinList()
  },
  getSkinList() {
    let that = this
    wx.showLoading({
      title: '加载中'
    })
    wx.request({
      url: API.skin,
      method: 'GET',
      dataType: 'json',
      success: function (res) {
        let data = res.data.data
        that.setData({
          skinList: data
        })
      },
      fail: function (res) {
        wx.showToast({
          title: '网络错误',
          icon: 'error',
        })
      },
      complete: function (res) {
        wx.hideLoading()
      },
    })
  },
  getInfo(e){
    let url=e.currentTarget.dataset.url
    if ( url.search('http') == -1 ){
      url='http:'+url
    }
    url = encodeURIComponent(url)
    wx.navigateTo({
      url: `/pages/skinInfo/skinInfo?params=${url}`
    })
  }
})